package com.hx.tx.springboot.service.impl;

import com.hx.tx.springboot.mapper.UserMapper;
import com.hx.tx.springboot.model.User;
import com.hx.tx.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author jxlgcmh
 * @date 2020-05-17 23:37
 * @description
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 还是需要添加 注解  否则报这样的错 No transaction aspect-managed TransactionStatus in scope
     * @param user
     */
    @Override
    @Transactional
    public void modifyUser(User user) {
        userMapper.update(user);
        // 故意产生异常
       throw new RuntimeException("fdgd");
    }
}
